package com.surpassun.emall.service;

import java.util.List;

import com.surpassun.emall.model.Permission;
import com.surpassun.emall.model.Role;

public interface PermissionService extends AbstractService<Permission> {

	public void addPermission(String name, String action);
	
	public void updatePermission(long permissionId, String name, String action);
	
	/**
	 * This method verify if a user has the permission to do an action or not.
	 * It will first check the user's roles and then
	 * check if one of these roles has the  permission or not to do an action.
	 * 
	 * @param userId
	 * @param action
	 * @return
	 */
	public boolean hasUserPermission(long userId, String action);
	
	/**
	 * This method verify if a role has the permission to do an action or not
	 * 
	 * @param role
	 * @param action
	 * @return
	 */
	public boolean hasRolePermission(Role role, String action);

	public void initializePermissions();

	public void addPermissionIfNotExist(List<String> actions);
	
}
